import io
from typing import Optional, Union
import pathlib

from chernc.treediff.gumtree.tree.tree_context import TreeContext


class TreeGenerator:
    def generate(self, r: Union[io.TextIOWrapper, str]) -> TreeContext:
        """Generate a TreeContext from the input stream."""
        raise NotImplementedError("Subclasses should implement this method")

    def generate_tree(self, r: Union[io.TextIOWrapper, str]) -> TreeContext:
        """Generate a TreeContext by reading from the provided reader."""
        return self.generate(r)
